using System.Collections.ObjectModel;
using HMCollada.Core;
using System.Xml;

namespace HMCollada.Core {
    internal struct HMColladaLibraryGeometries {
        internal string id;
        internal string name;
        internal HMColladaAsset asset;
        internal Collection<HMColladaGeometry> geometry;
    }
}

namespace HMCollada {
    internal partial class HMColladaLoader {
        internal static HMColladaLibraryGeometries LoadLibraryGeometries() {
            HMColladaLibraryGeometries newLibraryGeometries = new HMColladaLibraryGeometries();
            newLibraryGeometries.id = colladaReader.GetAttribute("id");
            newLibraryGeometries.name = colladaReader.GetAttribute("name");

            newLibraryGeometries.geometry = new Collection<HMColladaGeometry>();

            if (!colladaReader.IsEmptyElement) colladaReader.Read();
            do {
                if (colladaReader.NodeType != XmlNodeType.EndElement) {
                    switch (colladaReader.Name) {
                        case "asset": newLibraryGeometries.asset = LoadAsset(); break;
                        case "geometry": newLibraryGeometries.geometry.Add(LoadGeometry()); break;
                    }
                }

                if (!colladaReader.IsEmptyElement) colladaReader.Read();
            } while (colladaReader.Name != "library_geometries");

            if (colladaReader.IsEmptyElement) colladaReader.Read();
            return newLibraryGeometries;
        }
    }
}